package Web.controller;

import Web.domain.ResponseResult;
import Web.domain.entity.Comment;
import Web.service.CommentService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    //CommentService是我们在huanf-framework工程写的类
    private CommentService commentService;
    @ApiOperation("文章评论列表")
    @GetMapping("commentList/{articleId}")
    //ResponseResult是我们在huanf-framework工程写的类
    public ResponseResult commentList(@PathVariable("articleId") Long articleId){
        return commentService.CommentList(articleId);
    }
    @ApiOperation("发表评论")
    @PostMapping
    //在文章的评论区发送评论。ResponseResult是我们在huanf-framework工程写的类
    public ResponseResult addComment(@RequestBody Comment comment){
        return commentService.addComment(comment);
    }
}